Skip to content

fix(telemetry): review, findings and AI spend metrics reach Prometheus - #568

Merged
dan-petty merged 1 commit into
release/v0.2.23from
feat/564-otlp-metrics
Sep 25, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.23from
feat/564-otlp-metrics

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Found while fixing #547. With telemetry reaching the collector, the devops-cli and ai-spend dashboards still showed nothing useful:

  • devops_cli_review_duration_seconds and devops_cli_findings_total were emitted nowhere.
  • The AI spend metrics existed only on devops server's /metrics, which nothing scrapes.
  • Every metric was sent as a gauge. Each command is its own short-lived process, and the process id was in the resource, so no counter or histogram could accumulate. For example, increase(devops_cli_command_total[1h]) read a constant 1.

Changes

  • Deltas (telemetry/tracer.py):

    • increment_counter sends a monotonic delta sum;
    • record_histogram sends a delta histogram;
    • record_metric stays a gauge.

    Metrics carry a host resource: service.instance.id is the host name, which Prometheus stores as instance. There is no pid or version in it, so one host's commands add to one series.

  • Collector (k8s/otel/values.yaml): the deltatocumulative processor (max_stale: 1h) runs before remote write.

  • telemetry/instruments.py: the one list of sent metrics, with kind, unit and description. docs/TELEMETRY.md is generated from it; the old table named six metrics nothing emitted.

  • Reviews send their wall time by target type, and their findings by persona, severity and status.

  • AI calls count, as they happen, by provider, model, server and serving backend:

    • requests, and whether the cache answered;
    • prompt and completion tokens;
    • approximate spend.
  • Dashboards: active backends and spend by backend now come from sent counters.

Not verified in the cluster

The collector values were parsed in a test, not deployed. After merge:

  1. Upgrade the collector release with k8s/otel/values.yaml.
  2. Run a review with telemetry connected (devops telemetry connect).
  3. Check the review, findings and spend panels.

Tests

tests/test_telemetry_instruments.py covers:

  • every query in both dashboards names a sent series;
  • the counter payload and its host resource;
  • histogram buckets;
  • AI call metrics by backend, cached calls included;
  • review metrics;
  • the collector pipeline;
  • backend names.

test_docs now checks the generated table against the list.

uv run devops ci --force: 13/13 gates pass.

Closes #564

The devops-cli and ai-spend dashboards queried review and findings
metrics nothing emitted, and AI spend metrics only `devops server`
exposed. Every metric was also sent as a gauge from a short-lived
process, with the process id in its resource, so no counter or histogram
could accumulate.

Counters and histograms are now OTLP deltas from a per-host resource
(service.instance.id is the host), and the collector's
deltatocumulative processor keeps running totals before remote write.
telemetry/instruments.py lists every metric sent. Reviews send their
wall time and findings by persona, severity and status; AI calls count
requests, prompt and completion tokens and spend by backend and model as
they happen. Both dashboards read only sent metrics, checked by a test,
and docs/TELEMETRY.md is generated from the list instead of naming
metrics nothing emitted.

Closes #564
@dan-petty dan-petty added this to the v0.2.23 milestone Sep 25, 2026
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger priority/p2-medium Priority P2: standard work labels Sep 25, 2026
@dan-petty
dan-petty merged commit 630cc99 into release/v0.2.23 Sep 25, 2026
7 checks passed
@dan-petty
dan-petty deleted the feat/564-otlp-metrics branch September 25, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p2-medium Priority P2: standard work scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant